package com.example.liwushuo.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.R;
import com.example.liwushuo.bean.search.Search;
import com.lidroid.xutils.ViewUtils;

public class SearchGifAdapter extends AppAdapter<Search> {

	public SearchGifAdapter(Context context, List<Search> list) {
		super(context, list);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.one_item, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		Search search = list.get(position);
		holder.name.setText(search.getName());
		holder.price.setText(search.getPrice());
		holder.heart.setText(search.getLikes_count());
		BaseApp.getBitmapUtils().display(holder.img,
				search.getCover_image_url());

		return convertView;
	}

	private class ViewHolder {

		ImageView img;
		TextView name;
		TextView price;
		TextView heart;

		public ViewHolder(View convertView) {
			ViewUtils.inject(convertView);
			img = (ImageView) convertView.findViewById(R.id.img_one_id);
			name = (TextView) convertView.findViewById(R.id.one_item_name);
			price = (TextView) convertView.findViewById(R.id.one_item_price);
			heart = (TextView) convertView.findViewById(R.id.one_item_heart);
		}
	}

}
